/*
 *  Copyright 2016 The WebRTC Project Authors. All rights reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#import <AVFoundation/AVFoundation.h>
#import <Foundation/Foundation.h>
#include <AudioUnit/AudioUnit.h>

#import <VRTC/RTCMacros.h>

NS_ASSUME_NONNULL_BEGIN


@class RTC_OBJC_TYPE (RTCAudioSession);

RTC_OBJC_EXPORT
@protocol RTC_OBJC_TYPE
(RTCAudioSessionDelegate)<NSObject>

- (void)audioSession:(RTC_OBJC_TYPE (RTCAudioSession) *)audioSession  recordAudioData:(void *)data size:(int)size;

@end

#ifndef __JG_AUDIO_SESSION_QUEUE__
#define __JG_AUDIO_SESSION_QUEUE__
dispatch_queue_t getAudioSessionQueue(void);
#endif

RTC_OBJC_EXPORT
@interface RTC_OBJC_TYPE (RTCAudioSession) : NSObject

@property (nonatomic, weak) id<RTC_OBJC_TYPE(RTCAudioSessionDelegate)> delegate;

+ (instancetype)sharedInstance;

@property (nonatomic, assign) BOOL bAudioRecordMode;
@property (nonatomic, assign) BOOL bInterrupting;
@property (nonatomic, assign) BOOL bStart;
@property (nonatomic, assign,readonly) UInt32 bytesPerSample;

- (OSStatus)render:(AudioUnitRenderActionFlags *)flags timestamp:(const AudioTimeStamp*)timestamp outputBusNumber:(UInt32)outputBusNumber numFrames:(UInt32)numFrames ioData:(AudioBufferList *)ioData;

- (void)start;
- (void)stop;
- (void)mediaServiceStopped;
- (void)mediaServiceStarted;
- (void)freeRecordData:(void*)p;
- (void)beginInterrupting;
- (void)endInterrupting;
- (dispatch_queue_t)currentQueue;
- (void)resetSafeNetwork;
- (void)openSafeNetworkMode:(BOOL)bOpen;
- (void)closeRecord;


@end


NS_ASSUME_NONNULL_END
